home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 November / Chip Kasım 2001.iso / prog / amapi3d / data1.cab / Common / MACROS / OPENCURV.TCL < prev    next >
Encoding:
Text File  |  2000-08-11  |  1.0 KB  |  52 lines

  1. #SPEC -realnameid 0
  2.  
  3. # messages table
  4. #@@%000@@FR@@Ouvrir une courbe@@
  5. #@@%000@@US@@Open a curve@@
  6.  
  7. # no shape
  8. if {[llength [.amapi scene]] == 0} return
  9.  
  10. # it's not a curve
  11. newshape shape [.amapi current]
  12. if {[shape -curve] == 0} return
  13.  
  14. # curve has to be closed
  15. set closed [shape -closed]
  16. if {$closed == 0} return
  17.  
  18. # call tool placepoint
  19. set result [placepoint]
  20. #set orig [.match $result - -point3d]
  21. set orig $result
  22.  
  23. # user canceled ruler
  24. if {$orig == ""} return
  25.  
  26. # verify origin belongs to curve
  27. set points [shape -points]
  28. set numpts [llength $points]
  29. for {set i 0} {$i < $numpts} {incr i} {
  30.     if {[vertex dist [lindex $points $i] $orig] == 0} break
  31. }
  32. if {$i == $numpts} return
  33. set index $i
  34.  
  35. #calculate new shape
  36. newshape result {
  37.     addpoint [lindex $points $index]
  38.     set ind [expr {$index + 1}]
  39.     for {set i 0} {$i < $numpts} {incr i} {
  40.         if {$ind == $numpts} {
  41.             set ind 0
  42.         }
  43.         
  44.         addpoint [lindex $points $ind]
  45.         
  46.         incr ind
  47.     }
  48. }
  49. result -status open
  50. shape -checkout
  51. result -checkin
  52.